<?php

namespace app\admin\controller\repertory;

use app\admin\controller\Controller;
use app\admin\model\repertory\Bank as Models;

/**
 * 银行
 */
class Bank extends Controller
{
    /**
     * 列表
     */
    public function index()
    {
        $list = Models::getAll();
        return $this->renderSuccess('', compact('list'));
    }

    /**
     * 添加
     */
    public function add()
    {
        $model = new Models;
        // 新增记录
        if ($model->add($this->postData())) {
            return $this->renderSuccess('追加成功');
        }
        return $this->renderError('失敗を追加');
    }

    /**
     * 更新权限
     */
    public function edit()
    {
        // 权限详情
        $data = $this->postData();
        $model = Models::detail($data['id']);

        // 更新记录
        if ($model->edit($data)) {
            return $this->renderSuccess('更新成功');
        }
        return $this->renderError('更新失敗');
    }

    /**
     * 删除小程序
     */
    public function delete()
    {
        $message_id = $this->request->param('id');
        // 小程序详情
        $model = Models::detail($message_id);
        if (!$model->setDelete()) {
            return $this->renderError('操作に失敗');
        }
        return $this->renderSuccess('操作成功');
    }
}